import pymysql

class DB:
    def __init__(self):
        self.con = pymysql.connect(host='localhost',port=3306,user='root',password='123',db='park',charset='utf8',cursorclass=pymysql.cursors.DictCursor)
        self.cur = self.con.cursor()
    
    def insert(self,sql):
        self.cur.execute(sql)
        self.con.commit()
    
    def find(self,sql):
        self.cur.execute(sql)
        res = self.cur.fetchone()
        return res
    
    def findall(self,sql):
        self.cur.execute(sql)
        res = self.cur.fetchall()
        return res
    
    def close(self):
        self.cur.close()
        self.con.close()

db = DB()
